const Mock = require("mockjs");

function formatRes(res) {
  return JSON.parse(res.body)
}
let token = Mock.mock({
  "status": 200,
  'token': /^0x[a-f0-9]{18}$/
})

let error = {
  "status": 400,
  "message": '登录失败,账号或密码错误'
}
// 登录
Mock.mock(/goods\/login/, 'post', res => {
  const { username, password } = formatRes(res)
  if (username === 'admin' && password === '123') {
    return token
  } else {
    return error
  }
})
